home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
- #include <iostream.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- //Program concieved by David A. Scouten 04/02/93
- //completed and revised 07/26/93
-
- char code[9], password[9];
- int count=0;
- FILE *infptr, *outfptr;
-
- void main()
- {//begin main
- if ((infptr=fopen("password.dat","r"))==NULL) {//check for data file
- cout<<"\nCannot open 'password.dat' file.";
- goto WRITE_DATA;
- }
- while (!feof(infptr)) {//read data from file
- fscanf(infptr,"%s", &code);
- }//end while
- fclose(infptr);
- goto START;
-
- WRITE_DATA: //write new password
- if ((outfptr=fopen("password.dat","w"))==NULL) {//check for data file
- cout<<"\nCannot open 'password.dat' file";
- }
- cout<<"\nEnter NEW Password: ";
- cin>>code;
- fprintf(outfptr, "%s", code);//write data to file
- fclose(outfptr);
-
- START:
- //set tries counter
- count=3;
- while (count!=0){
-
- //display user prompt
- cout<<"\nTries Left: "<<count;
- cout<<"\nEnter CURRENT Password: ";
- //get keyboard input
- cin>>password;
-
- //password correctly entered
- if (strcmp(password,code)==0){
- cout<<"\nAccess Granted.\n";
- exit(0);
- }
- else
- {//password incorrectly entered
- cout<<"Incorrect Password!\n";
- count--;
- }//end if
-
- }//end while
-
- //system lockup
- cout<<"*Access Denied*";
- cout<<"\n*SYSTEM LOCKED*";
- LOCKUP:
- delay(100);
- goto LOCKUP;
-
- }//end main